
#include "commands-medit.h"
#include "creature.h"
#include "display.h"
#include "handler.h"
#include "mob.h"
#include "room.h"

/*MCmd::MCmd( void ) {
  name( "" );
  level( BUILDER );
  return;
}

bool MCmd::execute( Creature* creature, const std::string& args ) {

  return true;
}
*/

MCmdDescription::MCmdDescription( void ) {
  name( "description" );
  level( BUILDER );
  return;
}

bool MCmdDescription::execute( Creature* creature, const std::string& args ) {
  Handler* h = new TeditHandler( creature );
  h->getState()["vector"] = (void*)(new std::vector<std::string>(Display::refactor(creature->medit()->description())));
  h->getState()["name"] = (void*)(new std::string("Mob Description"));
  h->getState()["pointer"] = (void*)creature->medit()->descriptionp();
  creature->pushHandler( h );
  return true;
}

MCmdInformation::MCmdInformation( void ) {
  name( "information" );
  level( BUILDER );
  return;
}

bool MCmdInformation::execute( Creature* creature, const std::string& args ) {
  creature->send( Mob::getInformation( creature->medit() ) );
  return true;
}

MCmdKeywords::MCmdKeywords( void ) {
  name( "keywords" );
  level( BUILDER );
  syntax( "syntax: keywords <keyword 1> [keyword 2] [keyword 3] ..." );
  return;
}

bool MCmdKeywords::execute( Creature* creature, const std::string& args ) {
  std::vector<std::string> keywords;

  if ( args.empty() ) {
    creature->send( syntax() );
    return false;
  }

  keywords = Regex::explode( " ", args );
  creature->medit()->getKeywords().clear();
  for ( std::vector<std::string>::iterator it = keywords.begin(); it != keywords.end(); ++it ) {
    creature->medit()->addKeyword( *it );
  }
  creature->send( "You've set the mob keywords to \"%s\".", creature->medit()->getKeywordList().c_str() );

  return true;
}

